package dry.example.gui;

import javax.swing.*;
import java.awt.*;

public class WindowScreenResolution {
    public static void main(String[] args) {
        JFrame frame = new JFrame("测试");
        frame.setSize(400, 300);
        frame.setLocationRelativeTo(null); // 居中显示
        frame.setVisible(true);

        // 获取当前窗口所在屏幕设备
        GraphicsDevice gd = frame.getGraphicsConfiguration().getDevice();
        Rectangle bounds = gd.getDefaultConfiguration().getBounds();

        System.out.println("当前窗口所在屏幕的分辨率：");
        System.out.println("宽度: " + bounds.width);
        System.out.println("高度: " + bounds.height);
    }
}
